package com.zx.BookSeaReader.ui.bookinfo;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;

import com.zx.BookSeaReader.R;
import com.zx.BookSeaReader.base.BaseActivity;
import com.zx.BookSeaReader.common.APPCONST;
import com.zx.BookSeaReader.greendao.entity.Book;
import com.zx.BookSeaReader.greendao.entity.BookCommentBean;
import com.zx.BookSeaReader.greendao.service.CommentService;
import com.zx.BookSeaReader.util.TextHelper;
import com.zx.BookSeaReader.widget.RefreshLayout;
import com.zx.BookSeaReader.widget.itemdecoration.DividerItemDecoration;

import java.util.List;

import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.ButterKnife;
import butterknife.BindView;

public class BookInfoActivity extends BaseActivity {

    @BindView(R.id.ll_title_back)
    LinearLayout llTitleBack;
    @BindView(R.id.tv_title_text)
    TextView tvTitleText;
    @BindView(R.id.system_title)
    LinearLayout systemTitle;
    @BindView(R.id.iv_book_img)
    ImageView ivBookImg;
    @BindView(R.id.tv_book_name)
    TextView tvBookName;
    @BindView(R.id.tv_book_author)
    TextView tvBookAuthor;
    @BindView(R.id.tv_book_type)
    TextView tvBookType;
    @BindView(R.id.tv_book_desc)
    TextView tvBookDesc;
    @BindView(R.id.btn_add_bookcase)
    TextView btnAddBookcase;
    @BindView(R.id.btn_read_book)
    TextView btnReadBook;
    @BindView(R.id.tv_lately_update)
    TextView mTvLatelyUpdate;

    @BindView(R.id.refresh_layout1)
    RefreshLayout mRlRefresh;

    @BindView(R.id.tv_newest_chapter)
    TextView mTvNewestChapter;
    @BindView(R.id.tv_book_source)
    TextView mTvBookSource;

    @BindView(R.id.scroll)
    ScrollView mScroll;
    @BindView(R.id.tv_add_comment)
    TextView mTvAddComment;

    @BindView(R.id.comment_tv_floor)
    TextView mTvFloor;
    @BindView(R.id.comment_tv_name)
    TextView mTvAuthorName;
    @BindView(R.id.comment_tv_time)
    TextView mTvCommentTime;
    @BindView(R.id.comment_tv_content)
    TextView mTvContent;
    @BindView(R.id.item_comment)
    RelativeLayout mRlComment;
    @BindView(R.id.comment_tv_like_count)
    TextView mTvLikeCount;


    @BindView(R.id.refresh_rv_comments)
    RecyclerView mRvComment;

    private BookInfoPresenter mBookInfoPresenter;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_book_detail);

        ButterKnife.bind(this);
        setStatusBar(R.color.sys_line);


        mBookInfoPresenter = new BookInfoPresenter(this);
        mBookInfoPresenter.start();

    }
    @Override
    public void onResume() {
        super.onResume();
        mBookInfoPresenter.scrollUp();
    }

    public LinearLayout getLlTitleBack() {
        return llTitleBack;
    }

    public TextView getTvTitleText() {
        return tvTitleText;
    }

    public LinearLayout getSystemTitle() {
        return systemTitle;
    }

    public ImageView getIvBookImg() {
        return ivBookImg;
    }

    public TextView getTvBookName() {
        return tvBookName;
    }

    public TextView getTvBookAuthor() {
        return tvBookAuthor;
    }

    public TextView getTvBookType() {
        return tvBookType;
    }

    public TextView getTvBookDesc() {
        return tvBookDesc;
    }

    public TextView getBtnAddBookcase() {
        return btnAddBookcase;
    }

    public TextView getBtnReadBook() {
        return btnReadBook;
    }

    public TextView getTvLatelyUpdate() {
        return mTvLatelyUpdate;
    }
    public TextView getTvNewestChapter() {
        return mTvNewestChapter;
    }
    public RefreshLayout getRlRefresh() {
        return mRlRefresh;
    }

    public TextView getTvBookSource() {
        return mTvBookSource;
    }
    public TextView getTvAddComment() {
        return mTvAddComment;
    }
    public ScrollView getScroll() {
        return mScroll;
    }
    public RelativeLayout getRlComment() {
        return mRlComment;
    }
    public TextView getTvLikeCount() {
        return mTvLikeCount;
    }
    public TextView getTvFloor() {
        return mTvFloor;
    }
    public TextView getTvAuthorName() {
        return mTvAuthorName;
    }
    public TextView getTvCommentTime() {
        return mTvCommentTime;
    }
    public TextView getTvContent() {
        return mTvContent;
    }
//    public void refreshComment(List<BookCommentBean> mBookComments) {
//        TextHelper.showText(mBookComments.get(0).getFloorCount()+mBookComments.get(0).getCreateTime());
//        mBookCommentAdapter.refreshItems(mBookComments);
//        if (!(mRvComment.getAdapter() instanceof BookCommentAdapter)){
//            mRvComment.setAdapter(mBookCommentAdapter);
//        }
//    }

    public RecyclerView getRvComment() {
        return mRvComment;
    }
}
